<?php
declare (strict_types=1);

namespace app\validate;

use think\Validate;

class UserBankValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'frontal_photo' => 'require',
        'backside_photo' => 'require',
        'name' => 'require',
        'id_card' => 'require',
        'validity_period' => 'require',
        //'start_validity_period' => 'require',
        //'end_validity_period' => 'require',
        'cell_phone' => 'require|mobile',
        'bank_card_no' => 'require',
        'accounts_bank' => 'require',
        'bank_address' => 'require',
        'bank_sub_branch' => 'require',
        'reserved_number' => 'require|mobile',
        'account_type' => 'require',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'frontal_photo.require' => '身份证正面照不能为空',
        'backside_photo.require' => '身份证反面照不能为空',
        'name.require' => '姓名不能为空',
        'id_card.require' => '身份证号不能为空',
        'validity_period.require' => '证件有效期不能为空',
        //'start_validity_period.require' => '有效期开始时间不能为空',
        //'end_validity_period.require' => '有效期结束时间不能为空',
        'cell_phone.require' => '实名手机号不能为空',
        'cell_phone.mobile' => '手机号格式错误',
        'bank_card_no.require' => '卡号不能为空',
        'accounts_bank.require' => '开户行不能为空',
        'bank_address.require' => '开户行归属地不能为空',
        'bank_sub_branch.require' => '开户行支行不能为空',
        'reserved_number.require' => '预留手机号不能为空',
        'reserved_number.mobile' => '预留手机号格式错误',
        'account_type.require' => '账号类型不能为空',
    ];


    // edit 验证场景定义
    public function sceneEdit()
    {
        return $this->remove('id', 'require');
    }
}
